from Tkinter import *
from FrameMenu import FrameMenu
from servicios.Persistense import Persistense

class FormMain(Frame):

    _frame = None
    _root = None
    _logo = None
    _canvas = None
    _content = None
    _menu = None
    
    def __init__(self,master=None):
        Frame.__init__(self,master)
        master.title('Cuevana series checker')
#        master.wm_iconbitmap(Persistense.instance().get_icon_file_path())
        self.grid()
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=5)
        self.load_header()
        self.load_menu()

    def load_header(self):
        self._logo = PhotoImage (file=Persistense.instance().get_header_file_path())
        self._canvas = Canvas (self, width=500, height=100)
        self._canvas.create_image(0,0,image=self._logo, anchor=NW)
        self._canvas.grid(column=0, row=0, columnspan=2)

    def change_content(self, content):
        if not(self._content is None):
            self._content.grid_forget()
        self._content = content
        self._content.pre_load()
        self._content.grid(column=1,row=1, padx=3, sticky=W+N)
        self._content.post_load()

    def load_menu(self):
        self._menu = FrameMenu(self, self.change_content)
        self._menu.grid(column=0,row=1, sticky=W+N)